from fastapi import APIRouter
from fastapi import HTTPException,  Request
from schema.item import Item
from core.agent import build_agent


saver_router = APIRouter()


@saver_router.post("/messages/{session_id}")
async def get_message(request: Request, session_id: str):
    app = request.app
    agent =await build_agent(app)
    config = {"configurable": {"thread_id": session_id}}
    print(agent)
    state = await agent.aget_state(config)

    msgs = state.values
    print(msgs)
    

    return {"msg": msgs}



    
    
    